﻿using System.Collections.Generic;
using Sustainalytics.Entities;
using Sustainalytics.Synchronization.Validation.Entities.CorporateGovernance;
using Sustainalytics.Synchronization.Validation.ValidationRules.CorporateGovernance;
using Xunit;

namespace Sustainalytics.Synchronization.Validation.Tests
{
    [Trait("Category", "Unit")]

    public class GovernanceIndicatorScoreChangeYellowRule_should
    {
        private readonly GovernanceIndicatorScoreChangeYellowRule _sut = new GovernanceIndicatorScoreChangeYellowRule();

        [Fact]
        public void Return_true_when_score_change_is_lower_than_40_points()
        {
            var fake = new GovernanceValidationProfile
            {
                GovernanceIndicators = new List<GovernanceIndicator>
                                         {
                                             new GovernanceIndicator { Number = "G.1.1", Score = 10 },
                                             new GovernanceIndicator { Number = "G.1.2", Score = 20 },
                                             new GovernanceIndicator { Number = "G.1.3", Score = 30 },
                                         }
            };

            var mock = new GovernanceValidationProfile
            {
                GovernanceIndicators = new List<GovernanceIndicator>
                                         {
                                             new GovernanceIndicator { Number = "G.1.1", Score = 30 },
                                             new GovernanceIndicator { Number = "G.1.2", Score = 20 },
                                             new GovernanceIndicator { Number = "G.1.3", Score = 30 },
                                         }
            };
            var actual = _sut.IsValid(fake, mock);
            Assert.True(actual);
        }

        [Fact]
        public void Return_true_when_one_indicator_score_change_is_40_points()
        {
            var fake = new GovernanceValidationProfile
            {
                GovernanceIndicators = new List<GovernanceIndicator>
                                         {
                                             new GovernanceIndicator { Number = "G.1.1", Score = 10 },
                                             new GovernanceIndicator { Number = "G.1.2", Score = 20 },
                                             new GovernanceIndicator { Number = "G.1.3", Score = 30 },
                                         }
            };

            var mock = new GovernanceValidationProfile
            {
                GovernanceIndicators = new List<GovernanceIndicator>
                                         {
                                             new GovernanceIndicator { Number = "G.1.1", Score = 50 },
                                             new GovernanceIndicator { Number = "G.1.2", Score = 20 },
                                             new GovernanceIndicator { Number = "G.1.3", Score = 30 },
                                         }
            };
            var actual = _sut.IsValid(fake, mock);
            Assert.False(actual);
        }

        [Fact]
        public void Return_true_when_one_indicator_score_change_is_change_is_90_points()
        {
            var fake = new GovernanceValidationProfile
            {
                GovernanceIndicators = new List<GovernanceIndicator>
                                         {
                                             new GovernanceIndicator { Number = "G.1.1", Score = 10 },
                                             new GovernanceIndicator { Number = "G.1.2", Score = 20 },
                                             new GovernanceIndicator { Number = "G.1.3", Score = 30 },
                                         }
            };

            var mock = new GovernanceValidationProfile
            {
                GovernanceIndicators = new List<GovernanceIndicator>
                                         {
                                             new GovernanceIndicator { Number = "G.1.1", Score = 100 },
                                             new GovernanceIndicator { Number = "G.1.2", Score = 20 },
                                             new GovernanceIndicator { Number = "G.1.3", Score = 30 },
                                         }
            };
            var actual = _sut.IsValid(fake, mock);
            Assert.False(actual);
        }
    }
}